// TOWN SCRIPT
//    Town 15: Small Cave

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

// flags:
// 15, 2-4 = trap completion

begintownscript;

variables;

short i, mnlvl, mxlvl, nlvl, choice, trpdif;

body;

beginstate INIT_STATE;
	turn_off_training(1);

	mnlvl = 0;
	i = 0;
	// get max level in party
	while (i < 4) {
		nlvl = get_level(i);
		if (nlvl < mnlvl)
			mnlvl = nlvl;
		i = i + 1;
	}
	// make sliths stronger (balance this puppy)...
	if (mnlvl > 15) {
		set_creature_type_level(35, 18);
		set_creature_type_level(36, 17);
		set_creature_type_level(37, 17);
		set_level(17, 25);
	}
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;

break;

beginstate 10;
	if (get_flag(15, 0) == 0) {
		set_flag(15, 0, 1);
		message_dialog("There seems to be another secret room here.", "");
	}
break;

beginstate 11;
	play_sound(107);
	message_dialog("You open the chest and find a few sprigs of parsley.",
		"You take a sprig and search the chest but there is nothing else there.");
	change_spec_item(8, 1);
break;

beginstate 12;
	if (get_flag(15, 5) == 0) {
		set_flag(15, 5, 1);
		message_dialog("The small, musty cave seems to smell of reptiles.", "This must be home to many sliths.");
	}
break;
